<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller 
{
   			/* 充值信息记录 所有订单*/
	public function suoyou()
	{
		login('您好，请先登录');
		$yp_apply_order= M('','yp_apply_order','DB_CONFIG0');
		
		$count      = $yp_apply_order->count();
		$Page       = new \Org\Bjy\Page($count,15);
		$show       = $Page->show();
		$loadgame = $yp_apply_order->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		//dump($loadgame);die;
		$this->assign('page',$show);
				
		if(IS_POST)
		{//id 查询
			if($_POST['userid']!="")
			{
				$w['oper_account']=array('like','%'.I('post.userid').'%');//把数据写到空数组去  
				$loadgame=$yp_apply_order->where($w)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			//订单号查询
			if($_POST['order_no']!="")
			{
				$w['order_no']=array('like','%'.I('post.order_no').'%');//把数据写到空数组去  
				$loadgame=$yp_apply_order->where($w)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}				
			if($_POST['sdate']!="" || $_POST['edate']!="")
			{
				$arr['times']=array('between',array($_POST['sdate'],$_POST['edate']));
				$loadgame=M('yp_apply_order')->where($arr)->select();	
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			//订单状态
			// if($_POST['type']!="")
			// {
			// 	if(I('post.type')==1)
			// 	{
			// 		$loadgame=M('yp_apply_order')->where('order_status=1')->select();//订单成功的
			// 	}
			// 	if(I('post.type')==2)
			// 	{
			// 		$loadgame=M('yp_apply_order')->where('order_status=0')->select();//订单异常的	
			// 	}
			// 	if(I('post.type')==3)
			// 	{
			// 		$loadgame=M('yp_apply_order')->where('order_status=2')->select();//订单处理中的
			// 	}
			// }	
			//订单金额
			if($_POST['rmb']!="")
			{
				if(I('post.rmb')==1)
				{
					$loadgame=M('yp_apply_order')->where('order_money=4000')->select();//订单成功的
				}
				if(I('post.rmb')==2)
				{
					$loadgame=M('yp_apply_order')->where('order_money=11000')->select();//订单异常的	
				}
				if(I('post.rmb')==3)
				{
					$loadgame=M('yp_apply_order')->where('order_money=35000')->select();//订单处理中的
				}				
				if(I('post.rmb')==4)
				{
					$loadgame=M('yp_apply_order')->where('order_money=100000')->select();//订单处理中的
				}				
				if(I('post.rmb')==5)
				{
					$loadgame=M('yp_apply_order')->where('order_money=300000')->select();//订单处理中的
				}				
			}
		}
		$this->assign('loadgame',$loadgame);
		$this->display();
	}

}
